import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import {
  IsOptional
} from "class-validator";
import { CouponGoods } from './coupon_goods.entity';
import { UserCoupon } from './user_coupon.entities';

@Entity()
export class Coupon {
  @PrimaryGeneratedColumn({type: 'smallint'})
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar' ,length: 60})
  name:string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'decimal' ,width: 10})
  type_money:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'tinyint'})
  send_type:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'decimal' ,width: 10})
  min_amount:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'decimal' ,width: 10})
  max_amount:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'datetime'})
  send_start_date:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'datetime'})
  send_end_date:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'datetime'})
  use_start_date:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'datetime'})
  use_end_date:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'decimal', width: 10})
  min_goods_amount:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', comment:"转发次数"})
  min_transmit_num:number;

  @OneToMany(type => CouponGoods, couponGoods => couponGoods.coupon)
  couponGoods:CouponGoods[]

  @OneToMany(type => UserCoupon, userCoupon => userCoupon.coupon)
  userCoupon:UserCoupon[]
}
